﻿using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Friend2")]
namespace Fibot.Module.WangDianTong.Base;

/// <summary>
/// 查询条件
/// </summary>

public class BaseGetListInputVo
{
    /// <summary>
    /// 卖家账号
    /// </summary>
    public string sid { get; set; } = "";

    /// <summary>
    /// 接口账号
    /// </summary>
    public string appkey { get; set; } = "";

    /// <summary>
    /// 时间戳
    /// </summary>
    public int timestamp { get; set; }

    /// <summary>
    /// 签名
    /// </summary>
    public string sign { get; set; } = "";

}

static class Extensions
{
    public static Dictionary<string, object> ToDictionary(this object obj)
    {
        Dictionary<string, object> dict = new Dictionary<string, object>();
        Type t = obj.GetType();
        PropertyInfo[] properties = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);

        foreach (PropertyInfo property in properties)
        {
            if (property.PropertyType.AssemblyQualifiedName.ToLower().Contains("datetime"))
            {

                dict[property.Name] = Convert.ToDateTime(property.GetValue(obj)).ToString("yyyy-MM-dd HH:mm:dd");
            }
            else
            {
                dict[property.Name] = property.GetValue(obj);
            }
        }

        return dict;
    }
}